package com.quwan.manager.controller;

import com.quwan.common.BaseController;
import com.quwan.common.exception.ExpCode;
import com.quwan.common.result.ApiResult;
import com.quwan.common.result.PageResult;
import com.quwan.manager.controller.dto.AdminDto;
import com.quwan.manager.controller.dto.OrderCommentDto;
import com.quwan.manager.service.OrderCommentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author laozhang
 * @date 2022/1/13 14:02
 */
@Api(tags = "后台订单评论管理接口")
@RestController
@RequiredArgsConstructor
@RequestMapping("mgr/orderComment")
public class OrderCommentController  extends BaseController {

    private final OrderCommentService orderCommentService;
    @ApiOperation(value = "订单评论列表分页",notes = "<span style=\"color:red\">注意参数是否必填;</span>",httpMethod = "POST")
    @PostMapping("orderCommentListPage")
    public ApiResult<PageResult<OrderCommentDto>> AdminListPage(@RequestParam(defaultValue = "1") int page,
                                                                @RequestParam(defaultValue = "10") int size,
                                                                @RequestParam(required = false) String orderId,
                                                                @RequestParam(required = false) String mId,
                                                                @RequestParam(required = false) String commentMemberId,
                                                                @RequestParam(required = false) String memberName,
                                                                @RequestParam(required = false) String content,
                                                                @RequestParam(required = false) String beginTime,
                                                                @RequestParam(required = false) String endTime) {
        PageResult<OrderCommentDto> res = orderCommentService.getOrderCommentListPage(page, size, orderId, memberName, content, beginTime, endTime, mId, commentMemberId);
        return ApiResult.success(res);
    }

    @PostMapping("delAdmin")
    @ApiOperation("删除订单评论")
    public ApiResult delAdmin(@RequestParam(value = "id") Integer id){
        boolean success = orderCommentService.delOrderComment(id);
        if (success)
            return ApiResult.successMsg();
        else
            return ApiResult.failed();
    }
}
